package com.heima.account.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.heima.account.service.IAccountService;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author mcm
 * @since 2021-09-22
 */
@RestController
@RequestMapping("/account")
@CrossOrigin
public class AccountController {

    @Autowired
    private IAccountService accountService;

    /**
     * 扣减账户金额
     * @param userId 用户id
     * @param money 金额
     * @return
     */
    @PutMapping("/{userId}/{money}")
    public ResponseEntity deduct(@PathVariable("userId") Integer userId, @PathVariable("money") Integer money) {
        accountService.deduct(userId,money);
        return ResponseEntity.ok().build();
    }

}
